<div class="divColorbox">
    <div class="divColorbox_Header">
        <span><i class="fa fa-star"></i><span>用户加币页面</span></span>
        <a class="Refresh"></a><a class="Close"></a>
    </div>
    <div class="divColorbox_Body row">
        <div>
            <input name="User_ID" type="hidden"/>
            <div class="row">
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">用户ID</span>
                        <input id="User_ID" type="text" class="form-control" value="-------------" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">昵称</span>
                        <input id="NickName" type="text" class="form-control" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">性别</span>
                        <input id="Sex" type="text" class="form-control" disabled/>
                    </div>
                </div>
            </div>
            <div class="space-6"></div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">等级</span>
                        <input id="Level" type="text" class="form-control" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">金币</span>
                        <input id="Coin" type="text" class="form-control" disabled/>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">金豆</span>
                        <input id="Beans" type="text" class="form-control" disabled/>
                    </div>
                </div>
            </div>
            <div class="hr"></div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">加币类型</span>
                        <select id="Trade_Currency" class="form-control" name="IsRecommend">
                            <option value="" selected>--</option>
                            <option value="1">金币</option>
                            <option value="2">金豆</option>
                        </select>
                        <span class="input-group-addon"><i class="fa fa-home"></i></span>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">加减币</span>
                        <input id="Add_Coin" type="text" class="form-control"/>
                        <span class="input-group-addon"><i class="fa fa-home"></i></span>
                    </div>
                </div>

            </div>
            &nbsp;
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">备注</span>
                        <input id="Remark" type="text" class="form-control"/>
                        <span class="input-group-addon"><i class="fa fa-home"></i></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="divColorbox_Footer">
        <button type="button" id="btnEdit_Agree" class="btn btn-primary">
            <i class="fa fa-check"></i> 加币
        </button>
        <button type="button" id="btnEdit_Disagree" class="btn btn-warning">
            <i class="fa fa-close"></i> 减币
        </button>
        <button type="button" id="btnUndo"></button>
    </div>
</div>
<script>
    $(function () {
        if (_PageData.flag != 0) {
            $.KOC.Tips.Open("Error", _PageData.flag, {
                Timeout: 1000,
                onClose: function () {
                    parent.$.colorbox.close();
                }
            });
            return;
        }
        //////////////////////////////////////////////////////////
        //加币
        //////////////////////////////////////////////////////////
        $('#btnEdit_Agree').on('click', function () {
            var params = {
                Trade_Flag: 1,//交易方式  1：入账-1：出账
                msg: '加币成功'
            };
            Ajax_Init(params);
        });
        //////////////////////////////////////////////////////////
        //减币
        //////////////////////////////////////////////////////////
        $('#btnEdit_Disagree').on('click', function () {
            var params = {
                Trade_Flag: -1,//交易方式  1：入账-1：出账
                msg: '减币成功'
            };
            Ajax_Init(params);
        });
        function Ajax_Init(_parm) {
            var params = {
                Add_Coin: $.trim($('#Add_Coin').val()),
                User_ID: $.trim($('#User_ID').val()),
                Remark: $.trim($('#Remark').val()),
                Trade_Currency: $("#Trade_Currency option:selected").val(),
                Type: 1//相关类型：1-用户，2-公会
            };
            if (!params.Add_Coin) {
                $.KOC.Tips.Open('Error', '请输入加减币', {Timeout: 2000});
                return;
            }
            if(!params.Remark){
                $.KOC.Tips.Open('Error', '请输入描述', {Timeout: 2000});
                return;
            }
            if (!params.Trade_Currency) {
                $.KOC.Tips.Open('Error', '请选择豆币类型', {Timeout: 2000});
                return;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/user.user-info.admincurrencyupdate',
                type: 'post',
                dataType: 'json',
                data: {
                    Type: params.Type,//相关类型：1-用户，2-公会
                    User_ID: params.User_ID,//被操作的用户
                    Trade_Flag: _parm.Trade_Flag, //交易方式  1：入账-1：出账
                    Trade_Currency: params.Trade_Currency,//交易币种1:金币 2:金豆
                    Trade_Amt: params.Add_Coin,
                    Remark: params.Remark
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.KOC.Tips.Open("Error", data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }
                    $.KOC.Tips.Open('Success', _parm.msg, {
                        Timeout: 1000,
                        onClose: function () {
                            parent.$.colorbox.close();
//                            $.Common.ModalWindow.fnEnter();
                            parent.window.location.href = "/user-manage/info-manage/list";
                        }
                    });
                }
            });
        }

        //////////////////////////////////////////////////////////
        //数据绑定
        //////////////////////////////////////////////////////////
        $('#User_ID').val(_PageData.User_ID);
        $('#NickName').val(_PageData.NickName);
        $('#Level').val(_PageData.Level.Level);
        $('#Coin').val(_PageData.Coin);
        $('#Beans').val(_PageData.Beans);

        switch (_PageData.Sex) {
            case 1 :
                $("#Sex").val('男');
                break;
            case 2 :
                $("#Sex").val('女');
                break;
            default:
                $('#Sex').val('');
                break;
        }
    });
</script>